<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        background-color: pink;
        border-top: 20px solid black;
        padding: 20px;
      }

      .one {
        position: absolute;

        top: 150px;
        left: 20px;

        width: 200px;
        height: 200px;
        background-color: green;

        margin-left: 80px;
      }
    </style>
  </head>
  <body>
    <div class="box">我是小马哥</div>

    <div class="one"></div>
  </body>
  <script>
    // 获取元素真实宽高：offsetWidth，offsetHeight
    const box = document.querySelector(".box");
    console.log(box.offsetWidth); //200
    console.log(box.offsetHeight); //200
    console.log(box.offsetLeft); //8
    console.log(box.offsetTop); //8
  </script>
</html>
